package com.nuc.bigdata.controller;

import com.nuc.bigdata.orm.feign.NewsFeign;
import com.nuc.bigdata.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * @author JackLuo
 * @date 2019/11/18
 */
@RestController
@RequestMapping("/oa-news")
public class NewsController {

    private final NewsService newsService;

    @Autowired
    NewsController(NewsService newsService){
        this.newsService = newsService;
    }

    @GetMapping
    public ArrayList<NewsFeign> listNews(){
        return newsService.listNews();
    }


    @GetMapping("/{newsId}")
    public NewsFeign getNews(@PathVariable("newsId")String newsId){
        return newsService.getNewsByNewsId(newsId);
    }
}
